library math.core;

uses
  sci.expression in '..\..\sci.expression.pas',
  sci.types in '..\..\sci.types.pas',
  sci.constants in '..\..\sci.constants.pas',
  sci.log in '..\..\sci.log.pas',
  sci.functions in '..\..\sci.functions.pas',
  sci.sort in '..\..\sci.sort.pas',
  sci.simplifier in '..\..\sci.simplifier.pas',
  sci.term in '..\..\sci.term.pas',
  sci.equation in '..\..\sci.equation.pas',
  SysUtils,
  Classes;

{$R *.res}

procedure init_core; stdcall;
begin
  dbginit(ExtractFilePath(ParamStr(0)) + 'log\mathcore_debug.dbg');
end;

function calculate(data: TData): TData; stdcall;
var
  expr: TExpression;
begin
  expr := TExpression.Create(string(data.input));
  initData(Result);
  Result.output.Add('Result=' + floatToStr(expr.evalAsReal));
end;

function solve_equation(data: TData): TData; stdcall;
var
  equa: TEquation;
begin
  equa := TEquation.Create(string(data.input));
  initData(Result);
  Result.output.Add('Solution='+equa.Solve);
end;

exports
  init_core,
  calculate,
  solve_equation;

begin
end.
